<template>
  <div class="dashboard">
    <div class="cardArea">
      <div class="cardItem" style="margin-left:80px;position: relative;cursor: pointer" v-for="(val,index) in listObj" @click="toPlatForm(val)">
        <div class="item">
          <div><img style="width: 3rem;height: 2.9rem;" :src="val.imgSrc" alt="" ></div>
          <div>{{val.label}}</div>
          <div v-if="val.info">{{val.info}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import domain from '../../../domain.js'
  import qs from 'qs'
  const base = domain.target

  export default {
    name: 'Dashboard',
    components:{

    },
    computed: {

    },
    created() {
      console.log(window.location.origin)
      console.log(this.listObj)
      // this.origin = window.location.origin
      // this.origin = 'http://172.25.212.37'
    },
    data(){
      return {
        origin:"",
        listObj:[
          {
            label:"测管平台",
            url:window.location.origin+"/jettomanager/#/workbenchWait",
            value:1,
            imgSrc:require("./assets/favicon.png")
          },

          {
            label:"API自动化测试平台",
            url:"http://172.25.245.102:8081/#/login",
            value:4,
            imgSrc:require("./assets/yace.png")
          },
          {
            label:"UI自动化测试平台",
            url:"http://172.25.245.137/jettoui/#/login",
            value:5,
            imgSrc:require("./assets/ui.png")
          },
          {

            label:"YUMC百胜稳定性压测平台",
            url:"http://172.16.74.101:8083/login",
            value:7,
            imgSrc:require("./assets/favicon.png")
          },

          {
            label:"测试数据中心",
            // url:"http://itqa.hwwt2.com/data_center/#/",
            url:window.location.origin+"/data_center/#/",
            value:2,
            imgSrc:require("./assets/testdata.png")
          },
          {
            label:"接口感知平台",
            // url:"http://itqa.hwwt2.com/api/#/",
            url:window.location.origin+"/api/#/",
            value:3,
            imgSrc:require("./assets/api.png"),
            info:"开发中..."
          },
          {
            label:"禅道",
            url:"https://project.hwwt2.com/biz/user-login-L2Jpei9pbmRleC5odG1s.html",
            value:6,
            imgSrc:require("./assets/chandao.png")
          },
          {
            label:"性能测试申请",
            url:window.location.origin+"/pressures/#/applyTask",
            value:7,
            imgSrc:require("./assets/favicon.png")
          },
          {
            label:"测试报告汇总",
            url:window.location.origin+"/aggregate/#/report",
            value:8,
            imgSrc:require("./assets/favicon.png")
          },
        ],
      }
    },
    methods:{
      toPlatForm(data){
        console.log("data",data)
        if (data.value=="1"){
          /*this.$router.push({
            path:"/workbenchWait"
          })*/
          window.open(data.url)

        }

        if (data.value=="2"){
          // 获取数据中心菜单
          this.$post(`${base}/basic/buildMainMenu`, qs.stringify({
            menuTo:4
          }), {},3).then((res) => {
            if (res.data.code == 20000) {
              console.log("返回的菜单:",res.data)
              const menuData = res.data.obj
              localStorage.setItem('DmenuItems', JSON.stringify(menuData))
              // let url = ""
              // if (location.origin === 'http://172.25.245.137') {
              //   url='http://172.25.245.137/data_center/#/'
              // }
              // if (location.origin === 'http://itqa.hwwt2.com'){
              //   url='http://itqa.hwwt2.com/data_center/#/'
              // }
              // if (!url){
              //   url='http://itqa.hwwt2.com/data_center/#/'
              // }
              // window.open(url,"_self")
              window.open(data.url)

            }

          })
        }

        if (data.value>=3){
          window.open(data.url)
        }
      },
    }
  }
</script>

<style lang="scss" scoped>
  .dashboard {
    width: 99%;
    height: 100vh;
    margin: 0 auto;
    /*background-image: url("../../assets/loginBg.png");*/
    /*background-color: #f5f5f5;*/
  }
  .cardArea{
    width: 98%;
    margin-top: 0;
    border-radius: 3px;
    padding: 0 15px 0 15px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    /* align-items: center;*/
  }

  .cardItem{

    height: 200px;
    width: 225px;
    margin: 30px 0 0 20px;
    /*border-radius: 100px;*/
    /*border: 2px solid #e8e8e8;*/
/*    box-shadow:
      2px 2px 10px 3px #019bdd,
      inset  2px 2px 10px 3px #019bdd;*/
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    /*background-color: #0D2048;*/
    /*background-color:#fff;*/
    /*box-shadow: 3px 3px 3px 1px rgba(224, 200, 209, 0.2);*/
    /*background-image: linear-gradient(to left top,#fff,#fff,#a29bfe);*/
  }
  .cardItem:hover{
    transform: scale(1.1);
  }
  .item{
    width: 100%;
    height: 2.4rem;
    display: flex;
    flex-direction:column;
    justify-content: center;
    align-items: center;
  }
</style>
